package edu.unf.cen6940.service;

import edu.unf.cen6940.domain.Category;
import edu.unf.cen6940.domain.Faculty;
import edu.unf.cen6940.domain.Facultyresearch;
import edu.unf.cen6940.domain.Facultyresearchtostudent;
import edu.unf.cen6940.domain.Researchkeyword;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/rms_test-security-context.xml",
		"file:./resources/rms_test-service-context.xml",
		"file:./resources/rms_test-dao-context.xml",
		"file:./resources/rms_test-web-context.xml" })
@Transactional
public class FacultyresearchServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected FacultyresearchService service;

	/**
	 * Instantiates a new FacultyresearchServiceTest.
	 *
	 */
	public FacultyresearchServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Faculty entity
	 * 
	 */
	@Test
	public void deleteFacultyresearchFaculty() {
		// TODO: JUnit - Populate test inputs for operation: deleteFacultyresearchFaculty 
		Integer facultyresearch_facultyResearchId = 0;
		Integer related_faculty_facultyId = 0;
		Facultyresearch response = null;
		response = service.deleteFacultyresearchFaculty(facultyresearch_facultyResearchId, related_faculty_facultyId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFacultyresearchFaculty
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Facultyresearch entity
	 * 
	 */
	@Test
	public void countFacultyresearchs() {
		Integer response = null;
		response = service.countFacultyresearchs();
		// TODO: JUnit - Add assertions to test outputs of operation: countFacultyresearchs
	}

	/**
	 * Operation Unit Test
	 * Return all Facultyresearch entity
	 * 
	 */
	@Test
	public void findAllFacultyresearchs() {
		// TODO: JUnit - Populate test inputs for operation: findAllFacultyresearchs 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Facultyresearch> response = null;
		response = service.findAllFacultyresearchs(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllFacultyresearchs
	}

	/**
	 * Operation Unit Test
	 * Save an existing Facultyresearchtostudent entity
	 * 
	 */
	@Test
	public void saveFacultyresearchFacultyresearchtostudents() {
		// TODO: JUnit - Populate test inputs for operation: saveFacultyresearchFacultyresearchtostudents 
		Integer facultyResearchId = 0;
		Facultyresearchtostudent related_facultyresearchtostudents = new edu.unf.cen6940.domain.Facultyresearchtostudent();
		Facultyresearch response = null;
		response = service.saveFacultyresearchFacultyresearchtostudents(facultyResearchId, related_facultyresearchtostudents);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFacultyresearchFacultyresearchtostudents
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Researchkeyword entity
	 * 
	 */
	@Test
	public void deleteFacultyresearchResearchkeywords() {
		// TODO: JUnit - Populate test inputs for operation: deleteFacultyresearchResearchkeywords 
		Integer facultyresearch_facultyResearchId_1 = 0;
		Integer related_researchkeywords_researchKeywordId = 0;
		Facultyresearch response = null;
		response = service.deleteFacultyresearchResearchkeywords(facultyresearch_facultyResearchId_1, related_researchkeywords_researchKeywordId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFacultyresearchResearchkeywords
	}

	/**
	 * Operation Unit Test
	 * Save an existing Category entity
	 * 
	 */
	@Test
	public void saveFacultyresearchCategories() {
		// TODO: JUnit - Populate test inputs for operation: saveFacultyresearchCategories 
		Integer facultyResearchId_1 = 0;
		Category related_categories = new edu.unf.cen6940.domain.Category();
		Facultyresearch response = null;
		response = service.saveFacultyresearchCategories(facultyResearchId_1, related_categories);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFacultyresearchCategories
	}

	/**
	 * Operation Unit Test
	 * Save an existing Researchkeyword entity
	 * 
	 */
	@Test
	public void saveFacultyresearchResearchkeywords() {
		// TODO: JUnit - Populate test inputs for operation: saveFacultyresearchResearchkeywords 
		Integer facultyResearchId_2 = 0;
		Researchkeyword related_researchkeywords = new edu.unf.cen6940.domain.Researchkeyword();
		Facultyresearch response = null;
		response = service.saveFacultyresearchResearchkeywords(facultyResearchId_2, related_researchkeywords);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFacultyresearchResearchkeywords
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Facultyresearch entity
	 * 
	 */
	@Test
	public void deleteFacultyresearch() {
		// TODO: JUnit - Populate test inputs for operation: deleteFacultyresearch 
		Facultyresearch facultyresearch = new edu.unf.cen6940.domain.Facultyresearch();
		service.deleteFacultyresearch(facultyresearch);
	}

	/**
	 * Operation Unit Test
	 * Load an existing Facultyresearch entity
	 * 
	 */
	@Test
	public void loadFacultyresearchs() {
		Set<Facultyresearch> response = null;
		response = service.loadFacultyresearchs();
		// TODO: JUnit - Add assertions to test outputs of operation: loadFacultyresearchs
	}

	/**
	 * Operation Unit Test
	 * Save an existing Facultyresearch entity
	 * 
	 */
	@Test
	public void saveFacultyresearch() {
		// TODO: JUnit - Populate test inputs for operation: saveFacultyresearch 
		Facultyresearch facultyresearch_1 = new edu.unf.cen6940.domain.Facultyresearch();
		service.saveFacultyresearch(facultyresearch_1);
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findFacultyresearchByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findFacultyresearchByPrimaryKey 
		Integer facultyResearchId_3 = 0;
		Facultyresearch response = null;
		response = service.findFacultyresearchByPrimaryKey(facultyResearchId_3);
		// TODO: JUnit - Add assertions to test outputs of operation: findFacultyresearchByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Facultyresearchtostudent entity
	 * 
	 */
	@Test
	public void deleteFacultyresearchFacultyresearchtostudents() {
		// TODO: JUnit - Populate test inputs for operation: deleteFacultyresearchFacultyresearchtostudents 
		Integer facultyresearch_facultyResearchId_2 = 0;
		Integer related_facultyresearchtostudents_facultyResearchId = 0;
		Integer related_facultyresearchtostudents_studentId = 0;
		Integer related_facultyresearchtostudents_facultyId = 0;
		Facultyresearch response = null;
		response = service.deleteFacultyresearchFacultyresearchtostudents(facultyresearch_facultyResearchId_2, related_facultyresearchtostudents_facultyResearchId, related_facultyresearchtostudents_studentId, related_facultyresearchtostudents_facultyId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFacultyresearchFacultyresearchtostudents
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Category entity
	 * 
	 */
	@Test
	public void deleteFacultyresearchCategories() {
		// TODO: JUnit - Populate test inputs for operation: deleteFacultyresearchCategories 
		Integer facultyresearch_facultyResearchId_3 = 0;
		Integer related_categories_categoryId = 0;
		Facultyresearch response = null;
		response = service.deleteFacultyresearchCategories(facultyresearch_facultyResearchId_3, related_categories_categoryId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFacultyresearchCategories
	}

	/**
	 * Operation Unit Test
	 * Save an existing Faculty entity
	 * 
	 */
	@Test
	public void saveFacultyresearchFaculty() {
		// TODO: JUnit - Populate test inputs for operation: saveFacultyresearchFaculty 
		Integer facultyResearchId_4 = 0;
		Faculty related_faculty = new edu.unf.cen6940.domain.Faculty();
		Facultyresearch response = null;
		response = service.saveFacultyresearchFaculty(facultyResearchId_4, related_faculty);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFacultyresearchFaculty
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
